package lu.med.praxiswahl.wahlumed.client.patienten;

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import lu.med.praxiswahl.wahlumed.client.wclient.Main;

/**
 * 
 * @author Lars Holger Roth
 */
@SuppressWarnings("serial")
public class GeheimnummerEdit extends JDialog implements ActionListener {
	private PatientenPanel owner;
	private JTextArea input;

	public GeheimnummerEdit(PatientenPanel owner, Main win) {
		super(win, "Geheimnummer", true);
		this.owner = owner;
		this.setLayout(new GridLayout(2, 0));
		JPanel bPannel = new JPanel();
		input = new JTextArea();
		input.setLineWrap(true);
		input.setText(owner.getGeheimnummer());
		if (input.getText().equals("null"))
			input.setText("");
		this.add(input);
		JButton ok = new JButton("Ok");
		ok.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/login.png")));
		ok.addActionListener(this);
		JButton cancel = new JButton("Abbrechen");
		cancel.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/cancel.png")));
		cancel.addActionListener(this);
		bPannel.add(ok);
		bPannel.add(cancel);
		this.add(bPannel);
		this.pack();
		this.setLocation(500, 300);
		this.setVisible(true);
	}

	public void actionPerformed(ActionEvent e) {
		if (e.getActionCommand().equals("Ok")) {
			owner.setGeheimnummer(input.getText());
			this.setVisible(false);
		} else {
			this.setVisible(false);
		}
	}
}
